//reduceRight
function reduceRight(array, fn, total) {
    const len = array.length
    for (let i = len - 1; i >= 0; i--) {
        const fItem = array[i]
        if (i === len - 1 && total === undefined) {
            total = fItem
            continue
        }
        total = fn(total, fItem)
    }
    return total
}

export default reduceRight